import Vue from 'vue';
import Router from 'vue-router';

Vue.use(Router);

export default new Router({
    routes: [
        {
            path: '/',
            redirect: '/dashboard'
        },
        {
            path: '/',
            component: () => import(/* webpackChunkName: "home" */ '../components/common/Home.vue'),
            meta: { title: '自述文件' },
            children: [
                {
                    path: '/dashboard',
                    component: () => import(/* webpackChunkName: "dashboard" */ '../components/page/Dashboard.vue'),
                    meta: { title: '系统首页' }
                },
                {
                    path: '/feedback',
                    component: () => import(/* webpackChunkName: "dashboard" */ '../components/page/Feedback.vue'),
                    meta: { title: '建议' }
                },
                {
                    path: '/icon',
                    component: () => import(/* webpackChunkName: "icon" */ '../components/page/Icon.vue'),
                    meta: { title: '自定义图标' }
                },
                {
                    path: '/users',
                    component: () => import(/* webpackChunkName: "table" */ '../components/page/users.vue'),
                    meta: { title: '会员管理' },
                    beforeEnter: (to, from, next) => {
                        if (localStorage.ms_username == 'admin') {
                            next();
                        } else {
                            next({
                                path: '/403',
                                query: { redirect: to.fullPath }
                            });
                        }
                    }
                },
                {
                    path: '/goodUpd',
                    component: () => import(/* webpackChunkName: "table" */ '../components/page/GoodUpd.vue'),
                    meta: { title: '商品上下架' }
                },
                {
                    path: '/goodCato',
                    component: () => import(/* webpackChunkName: "table" */ '../components/page/GoodCategory.vue'),
                    meta: { title: '商品分类' }
                },
                {
                    path: '/goodpic',
                    component: () => import(/* webpackChunkName: "table" */ '../components/page/GoodPic.vue'),
                    meta: { title: '商品图片' }
                },
                {
                    path: '/waitShip',
                    component: () => import(/* webpackChunkName: "table" */ '../components/page/WaitShip.vue'),
                    meta: { title: '待发货订单' }
                },
                {
                    path: '/afterSale',
                    component: () => import(/* webpackChunkName: "table" */ '../components/page/AfterSalesOrder.vue'),
                    meta: { title: '请求售后订单' }
                },
                {
                    path: '/suggest',
                    component: () => import(/* webpackChunkName: "table" */ '../components/page/Suggest.vue'),
                    meta: { title: '底部推荐栏' },
                    beforeEnter: (to, from, next) => {
                        if (localStorage.ms_username == 'admin') {
                            next();
                        } else {
                            next({
                                path: '/403',
                                query: { redirect: to.fullPath }
                            });
                        }
                    }
                },
                {
                    path: '/suggestbig',
                    component: () => import(/* webpackChunkName: "table" */ '../components/page/SuggestBig.vue'),
                    meta: { title: '大类推荐栏' },
                    beforeEnter: (to, from, next) => {
                        if (localStorage.ms_username == 'admin') {
                            next();
                        } else {
                            next({
                                path: '/403',
                                query: { redirect: to.fullPath }
                            });
                        }
                    }
                },


                {
                    path: '/table',
                    component: () => import(/* webpackChunkName: "table" */ '../components/page/BaseTable.vue'),
                    meta: { title: '基础表格' }
                },
                {
                    path: '/tabs',
                    component: () => import(/* webpackChunkName: "tabs" */ '../components/page/Tabs.vue'),
                    meta: { title: 'tab选项卡' }
                },
                {
                    path: '/information',
                    component: () => import(/* webpackChunkName: "tabs" */ '../components/page/information.vue'),
                    meta: { title: '客服信息' }
                },
                {
                    path: '/im',
                    component: () => import(/* webpackChunkName: "tabs" */ '../views/Im.vue'),
                    meta: { title: '聊天' }
                },
                {
                    path: '/talk',
                    component: () => import(/* webpackChunkName: "tabs" */ '../components/page/Talk.vue'),
                    meta: { title: '聊天talk' }
                },
                {
                    path: '/tribunal',
                    component: () => import(/* webpackChunkName: "tabs" */ '../components/page/Tribunal.vue'),
                    meta: { title: '小法庭' },
                    children: [

                    ]
                },
                {
                    path: 'tribunalDetail', //法庭记录
                    name: 'tribunalDetail',
                    component: ()=> import('../components/page/tribunalDetail'),
                    meta: { title: '小法庭详情' },
                    children: [
                        {
                            path: 'presentation',
                            name: 'presentation',
                            component: ()=> import('../components/page/presentation')
                        },
                        // {
                        //     path: 'transactionRecords',
                        //     name: 'transactionRecords',
                        //     component: ()=> import('../components/page/transactionRecords')
                        // }
                    ]
                },
                {
                    path: '/form',
                    component: () => import(/* webpackChunkName: "form" */ '../components/page/BaseForm.vue'),
                    meta: { title: '基本表单' }
                },
                {
                    // 富文本编辑器组件
                    path: '/editor',
                    component: () => import(/* webpackChunkName: "editor" */ '../components/page/VueEditor.vue'),
                    meta: { title: '富文本编辑器' }
                },
                {
                    // markdown组件
                    path: '/markdown',
                    component: () => import(/* webpackChunkName: "markdown" */ '../components/page/Markdown.vue'),
                    meta: { title: 'markdown编辑器' }
                },
                {
                    // 图片上传组件
                    path: '/upload',
                    component: () => import(/* webpackChunkName: "upload" */ '../components/page/Upload.vue'),
                    meta: { title: '文件上传' }
                },
                {
                    // vue-schart组件
                    path: '/charts',
                    component: () => import(/* webpackChunkName: "chart" */ '../components/page/BaseCharts.vue'),
                    meta: { title: 'schart图表' }
                },
                {
                    // vue-schart组件
                    path: '/baseEcharts',
                    component: () => import(/* webpackChunkName: "chart" */ '../components/page/BaseECharts.vue'),
                    meta: { title: 'schart图表' }
                },
                {
                    // echart组件
                    path: '/monthChart',
                    component: () => import(/* webpackChunkName: "chart" */ '../components/page/MonthCharts.vue'),
                    meta: { title: '月销售趋势' }
                },
                {
                    path: '/quarterChart',
                    component: () => import(/* webpackChunkName: "chart" */ '../components/page/QuarterCharts.vue'),
                    meta: { title: '季度销售趋势' }
                },
                {
                    path: '/yearChart',
                    component: () => import(/* webpackChunkName: "chart" */ '../components/page/YearCharts.vue'),
                    meta: { title: '年销售趋势' }
                },
                {
                    // 拖拽列表组件
                    path: '/drag',
                    component: () => import(/* webpackChunkName: "drag" */ '../components/page/DragList.vue'),
                    meta: { title: '拖拽列表' }
                },
                {
                    // 拖拽Dialog组件
                    path: '/dialog',
                    component: () => import(/* webpackChunkName: "dragdialog" */ '../components/page/DragDialog.vue'),
                    meta: { title: '拖拽弹框' }
                },
                {
                    // 国际化组件
                    path: '/i18n',
                    component: () => import(/* webpackChunkName: "i18n" */ '../components/page/I18n.vue'),
                    meta: { title: '国际化' }
                },
                {
                    // 权限页面
                    path: '/permission',
                    component: () => import(/* webpackChunkName: "permission" */ '../components/page/Permission.vue'),
                    meta: { title: '权限测试', permission: true }
                },
                {
                    path: '/404',
                    component: () => import(/* webpackChunkName: "404" */ '../components/page/404.vue'),
                    meta: { title: '404' }
                },
                {
                    path: '/403',
                    component: () => import(/* webpackChunkName: "403" */ '../components/page/403.vue'),
                    meta: { title: '403' }
                },
                {
                    path: '/donate',
                    component: () => import(/* webpackChunkName: "donate" */ '../components/page/Donate.vue'),
                    meta: { title: '支持作者' }
                }
            ]
        },
        {
            path: '/login',
            component: () => import(/* webpackChunkName: "login" */ '../components/page/Login.vue'),
            meta: { title: '登录' }
        },
        {
            path: '/customerService',
            component: () => import(/* webpackChunkName: "login" */ '../components/page/customerService'),
            meta: { title: '客服' }
        },
        {
            path: '*',
            redirect: '/404'
        }
    ]
});
